var customElementTypeProvider = (function () {
    return function (options) {
        var addElementTypes = function (context) {
            context.addPrintElementTypes("testModule",[
                    new hiprint.PrintElementTypeGroup("常规", [
                        { tid: 'testModule.text', text: '文本', "options": {
                            "textAlign": "center", "title":"单行文本","field":"","testData":"text","textType": 'text',"fontFamily":"Microsoft YaHei"}},
                        {tid:"testModule.image",text: '图片', type: 'image', "options":{"field":"","src":"./img/logo.png"}},
                        {tid: 'testModule.qrcode', text: '二维码',"options": {
                            "height": 50,"width": 50,"title":"qrcode","field":"","testData":"qrcode","textType": "qrcode"}},
                        {tid: 'testModule.barcode', text: '条形码', "options": {
                            "width": 150, "height": 35,"textAlign": "center", "title":"barcode","field":"","testData":"barcode","textType": 'barcode',"fontFamily":"Microsoft YaHei"}},
                        { tid: 'testModule.longText', text: '多行长文本', data: '', type: 'longText', "options": {
                            "width": 150, "height": 35,"textAlign": "center", "title":"多行<br>长文本","field":"","testData":"longText","fontFamily":"Microsoft YaHei"}},
                        { tid: 'testModule.tableCustom',title: '表格',field: 'table_printDatast', type: 'tableCustom'
							},
						{ tid: 'testModule.qrcodetable',title: '二维码表',field: 'table_printDatast', type: 'tableCustom'
							},
						{ tid: 'testModule.barcodetable',title: '条形码表',field: 'table_printDatast', type: 'tableCustom'
							},
                        {
                            tid: 'testModule.html', title: 'html',
                            formatter: function (data, options) {
                                return $('<div style="height:50pt;width:50pt;background:red;border-radius: 50%;"></div>');
                            },
                            type: 'html'
                        }
                    ]),
                    new hiprint.PrintElementTypeGroup("辅助", [
                        {
                            tid: 'testModule.hline',
                            text: '横线',
                            type: 'hline'
                        },
                        {
                            tid: 'testModule.vline',
                            text: '竖线',
                            type: 'vline'
                        },
                        {
                            tid: 'testModule.rect',
                            text: '矩形',
                            type: 'rect'
                        },
                        {
                            tid: 'testModule.oval',
                            text: '椭圆',
                            type: 'oval'
                        }
                    ]),
                    new hiprint.PrintElementTypeGroup("标识", [
                        {tid:"testModule.cesi",text: '图片', type: 'image', "options":{"field":"","src":"./img/biaos/测试.svg"}},
                        {tid:"testModule.jingao",text: '图片', type: 'image', "options":{"field":"","src":"./img/biaos/警告.svg"}}
                    ]),
					new hiprint.PrintElementTypeGroup("表格/其他", [
					  {tid: 'aProviderModule.table', title: '订单数据',
					    type: 'table',
					    options: {
					      field: 'table_printDatast',
					      tableHeaderRepeat: 'first',
					      tableFooterRepeat: 'last',
					      fields: [
					        {text: 'ID', field: 'ID'},
					        {text: '姓名', field: '姓名'},
					        {text: '性别', field: '性别'},
					        {text: '金额', field: '金额'},
					        {text: '数量', field: '数量'},
					      ],
					    },
					    editable: true,
					    columnDisplayEditable: true,//列显示是否能编辑
					    columnDisplayIndexEditable: true,//列顺序显示是否能编辑
					    columnTitleEditable: true,//列标题是否能编辑
					    columnResizable: true, //列宽是否能调整
					    columnAlignEditable: true,//列对齐是否调整
					    isEnableEditField: true, //编辑字段
					    isEnableContextMenu: true, //开启右键菜单 默认true
					    isEnableInsertRow: true, //插入行
					    isEnableDeleteRow: true, //删除行
					    isEnableInsertColumn: true, //插入列
					    isEnableDeleteColumn: true, //删除列
					    isEnableMergeCell: true, //合并单元格
					    columns: [
					      [
					        {title: 'ID', align: 'center', field: 'ID', width: 150},
					        {title: '姓名', align: 'center', field: '姓名', width: 80},
					        {title: '性别', align: 'center', field: '性别', width: 80, checked: false},
					        {title: '金额', align: 'center', field: '金额', width: 100, checked: false},
					        {title: '数量', align: 'center', field: '数量', width: 100},
					      ],
					    ],
					    rowsColumnsMerge: function (data, row, index) {
					      // 返回一个数组,参数一为列合并数,参数二为行合并数, 被合并的行或者列值设为0
					      if (index == 0) {
					        return [1, data.INDEX % 2 == 1 ? 2 : 1]
					      } else if (index > 0 && index < 2) {
					        return [data.INDEX % 2 == 1 ? 0 : 1, 1]
					      } else {
					        return [data.INDEX % 2 == 1 ? 2 : 0, 1]
					      }
					    },
					    footerFormatter: function (options, rows, data, currentPageGridRowsData) {
					      if (data && data['totalCap']) {
					        return `<td style="padding:0 10px" colspan="100">${'应收金额大写: ' + data['totalCap']}</td>`
					      }
					      return '<td style="padding:0 10px" colspan="100">应收金额大写: </td>'
					    },
					  },
					  {tid: 'aProviderModule.customText', title: '文本', customText: '自定义文本', custom: true, type: 'text'},
					  {
					    tid: 'aProviderModule.longText', title: '长文本', type: 'longText', options: {
					      field: 'test.longText',
					      width: 200,
					      testData: '长文本分页/不分页测试'
					    },
					  }
					])
                ]
            );
        };
        return {
            addElementTypes: addElementTypes
        };
    };
})();